<?php if(!$this->isSelf): ?><div id="choose_concessions_container"><?php endif; ?>
<form id="choose_concessions_form" action="<?php echo $this->getUrl(NULL, "choose-concessions")?>" method="post">
<?php echo $this->toolbar->toHtml();?>
<?php echo $this->grid->toHtml(); ?>
<input type="hidden" name="isself" value="1"/>
<input type="hidden" id="selected" name="selected" value="<?php echo $this->selected ?>"/>
<input type="hidden" name="callback" value="<?php echo $this->callback ?>"/>
<input type="hidden" name="elementid" value="<?php echo $this->elementId ?>"/>
<input type="hidden" name="poi" value="<?php echo $this->poi ?>"/>
</form>
<script language="javascript" type="text/javascript">
Kdf.globals.grids['choose_concessions_grid'] = new Kdf.Ui.Grid({
    grid:$('#choose_concessions_grid')
});
Kdf.globals.forms['choose_concessions_form'] = new Kdf.Ui.Form({
    form:$('#choose_concessions_form')
});
$('#choose_concessions_form').submit(function(){
    $('#choose_concessions_form').ajaxSubmit({
       success:function(responseText, statusText, xhr, $form){
           $('#choose_concessions_container').html(responseText);
       }
    });
    return false;
});
</script>
<?php if(!$this->isSelf): ?>
</div>
<script language="javascript" type="text/javascript">
function clearForm(){
    $('input[name^="filter"]').val('');
    $('#choose_concessions_form').submit();
}
function chooseMulti(){
    $('#choose_concessions_form :checked').each(function(){
        returnChoose($(this));
    })
}
function returnChoose(el){
    var callback = <?php echo $this->callback ?>;
    var data = {};
    var tr = $($(el).parent().parent());
    data.id = tr.attr('id').substring(3);
    data.text = tr.find('td[field="name"]').text();
    callback(data);
    var selected = $('#selected').val().split(',');
    selected.push(data.id);
    $('#selected').val(selected.join(','));
    $(el).parent().parent().remove();
}
$('#choose_concessions_container').dialog({
    width:800,
    height:600,
    resizable: false,
    title: '<?php echo $this->dialogTitle?>',
    modal: true,
    close: function(event, ui){
        $(this).dialog( "destroy" );
        $('#choose_concessions_container').remove();
    }
});
</script>
<?php endif; ?>